const mongoose = require('mongoose');
const Schema = mongoose.Schema;

// 系统配置模型
const systemConfigSchema = new Schema({
  key: { type: String, required: true, unique: true },
  value: Schema.Types.Mixed,
  description: String,
  config_group: String,
  visible_roles: [{
    type: Schema.Types.ObjectId, 
    ref: 'Role'
  }],
  course_settings: {
    max_file_size: Number,
    allowed_video_types: [String],
    max_duration: Number
  },
  activity_settings: {
    max_concurrent: Number,
    min_duration: Number,
    max_discount: Number
  },
  file_storage: {
    provider: {
      type: String,
      enum: ["local", "aws_s3", "aliyun_oss"],
      default: "local"
    },
    max_size: { type: Number, default: 100 }, // MB
    allowed_types: { 
      type: [String], 
      default: ["image/jpeg", "image/png", "video/mp4"] 
    },
    cdn_domain: String
  }
});

module.exports = mongoose.model('SystemConfig', systemConfigSchema);
